Title: Year 12 / Computer Science / Practical / 11 - Programming / 11.3 - Structured Programming

Q: Define what is meant by procedure
A: subroutine that performs a specific task without returning a value

Q: Write down the pseudocode to declare a procedure (no parameters)
[[typebox:Back]]
A: PROCEDURE identifier()
  ...
ENDPROCEDURE

Q: Define what is meant by a function
A: subroutine that performs a specific task and returns a value

Q: Write down the pseudocode to declare a function (no parameters)
[[typebox:Back]]
A: FUNCTION identifier() RETURNS datatype
  ...
  RETURN identifier1
ENDFUNCTION

Q: Explain what is meant by pass by value
A: when a copy of the current actual value is passed into subroutine, changes applied to value wont be effective outside subroutine in calling program

Q: Explain what is meant by pass by reference
A: pointer to memory location of variable is passed into subroutine, changes applied to variables value will be effective outside subroutine in calling program

Q: Describe what is meant by argument
A: actual input expression or value with which subroutine called

Q: Describe what is meant by parameter
A: variables used inside subroutine which take values passed into subroutine at call time

Q: Describe what is meant by subroutine interface
A: the parameters being passed between subroutine and calling program

Q: Describe what is meant by function/procedure header
A: first line of function or procedure definition that shows identifier and parameter list

Q: State the psuedocode for calling a subroutine
A: CALL identifier

Q: Write pseudocode for a procedure that passes parameters by value and by reference
[[typebox:Back]]
A: PROCEDURE identifier(BYVAL identifier1: datatype, BYREF identifier2: datatype)
  ...
ENDPROCEDURE

Q: Describe the benefits of using procedures and functions
A: lines of code can be re used, dont have to be repeated, can be tested and improved independently of program, easy to share with other programs, creates routines that can be called like built in command